﻿using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using SharppiFlowEditor.controllers;
using SharppiFlowEditor.views;


namespace SharppiFlowEditor.models
{
    class EndNode : AbstractNode
    {
        
        //private Rectangle _boundingRect;

        public EndNode(int x, int y, int width, int height)
        {
            _boundingRect = new Rectangle(x, y, width, height);
        }

        public override void draw(Graphics g)
        {
            draw(g, 1.0);
        }

        public override void draw(Graphics g, double zoomSize)
        {
            SizeF titleSize = g.MeasureString(Title, nodeFont);

            _boundingRect.Width = Math.Max(70, (int)titleSize.Width + 20);
            _boundingRect.Height = Math.Max(40, (int)titleSize.Height + 20);

            Rectangle relativeSizeRect = getRelativeBoundingRect(zoomSize);

            if (_bgColor != null)
            {
                g.FillEllipse(new SolidBrush(_bgColor), relativeSizeRect);
            }
            g.DrawEllipse(new Pen(Color.Black, 0.5F), relativeSizeRect);
            g.DrawString(Title,
                        nodeFont, 
                        new SolidBrush(Color.Black),
                        relativeSizeRect.X + (relativeSizeRect.Width / 2 - (int)titleSize.Width / 2),
                        relativeSizeRect.Y + (relativeSizeRect.Height / 2 - (int)titleSize.Height / 2));
        }

        public override Rectangle getBoundingRect()
        {
            return this._boundingRect;
        }

        public override void setBoundingRectLocation(int x, int y)
        {
            this._boundingRect.Location = new Point(x, y);
        }
    }
}
